import os
import string
import random

import cv2
import flask
import json
from flask import request, redirect
from minio import Minio

import urllib3
import certifi
from datetime import timedelta

# obj下载文件夹

dwdir = 'E:\\video\\bendi\\ks'
# 输出图片到当前目录vedio文件夹下
cvDir = '/usr/src/app/cvimage/'
# 图片上传到minio bucket
imgpushdir = 'file'

minioClient = Minio('115.29.55.141:9001',
                    access_key='admin',
                    secret_key='1234554321',
                    secure=False)

server = flask.Flask(__name__)


def snum(org=12, chars=string.ascii_uppercase + string.digits):
    return ''.join(random.choice(chars) for _ in range(org))


# flask route service
@server.route('/<picsize>/<bucket>/<path:obj>', methods=['get', 'post'])

def imgrest(picsize,bucket,obj):
    stat = None
    try:
        stat = minioClient.stat_object('izxcs', '/file/f7b2521ff3502720a60052d9ee3554e2.mp4111')
        print(stat)
    except BaseException as err:
        print(err)




    resu = {'code': 404, 'data': 'url', 'message': "error"}
    return json.dumps(resu, ensure_ascii=False)

if __name__ == '__main__':
    server.run(debug=True, port=8888, host='0.0.0.0')
